package cn.iocoder.yudao.module.shop.dal.mysql.giftcard;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.shop.dal.dataobject.giftcard.ShopGiftCardDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.shop.controller.admin.giftcard.vo.*;
import org.omg.PortableServer.RequestProcessingPolicyValue;

/**
 * 礼品卡 Mapper
 *
 * @author 曹建伟
 */
@Mapper
public interface ShopGiftCardMapper extends BaseMapperX<ShopGiftCardDO> {

    default PageResult<ShopGiftCardDO> selectPage(ShopGiftCardPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ShopGiftCardDO>()
                .eqIfPresent(ShopGiftCardDO::getGiftId, reqVO.getGiftId())
                .eqIfPresent(ShopGiftCardDO::getActivated, reqVO.getActivated())
                .eqIfPresent(ShopGiftCardDO::getCardId, reqVO.getCardId())
                .eqIfPresent(ShopGiftCardDO::getBinded, reqVO.getBinded())
                .eqIfPresent(ShopGiftCardDO::getMobile, reqVO.getMobile())
                .eqIfPresent(ShopGiftCardDO::getTenantId, reqVO.getTenantId())
                .betweenIfPresent(ShopGiftCardDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShopGiftCardDO::getId));
    }

    default List<ShopGiftCardDO> selectList(ShopGiftCardExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ShopGiftCardDO>()
                .eqIfPresent(ShopGiftCardDO::getGiftId, reqVO.getGiftId())
                .eqIfPresent(ShopGiftCardDO::getBinded, reqVO.getBinded())
                .eqIfPresent(ShopGiftCardDO::getMobile, reqVO.getMobile())
                .betweenIfPresent(ShopGiftCardDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShopGiftCardDO::getId));
    }

}
